package org.jay.angla.dialog;

import java.util.List;

import org.jay.angla.onlab.R;
import org.jay.angla.utils.Contants;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;

public class HistoryExperimentDialog extends Dialog {

	private String[] names;
	private ListView mListView;
	private Context mContext;
	private int mId;

	public void setId(int id) {
		mId = id;
	}

	public int getId() {
		return mId;
	}

	public HistoryExperimentDialog(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		mContext = context;
		setThisDialog();
		setTitle(context.getString(R.string.history_dialog_title));
	}

	public void setData(List<String> names) {
		int count = names.size();
		this.names = new String[count];
		for (int i = 0; i < count; i++) {
			this.names[i] = names.get(i);
		}
		mListView.setAdapter(new ArrayAdapter<String>(mContext,
				android.R.layout.simple_list_item_1, names));
	}

	private void setThisDialog() {
		View mView = LayoutInflater.from(getContext()).inflate(
				R.layout.dialog_history_experiment, null);
		super.setContentView(mView);
		mListView = (ListView) mView.findViewById(R.id.lv_history);
	}

	public void setOnHistoryListener(OnItemClickListener listener) {
		mListView.setOnItemClickListener(listener);
	}
}
